<template>
  <el-row>


  </el-row>
  <el-row>
    <el-col :span="6">
      <el-menu class="el-menu--vertical-demo" text-color="#fff"
               background-color="pink">
        <el-icon><House /></el-icon>
        <span>进销存管理系统</span>
        <el-sub-menu index="1" v-if="limitList.includes(1) || limitList.includes(2)">
          <template #title>
            <el-icon><Document /></el-icon>
            <span>资料管理</span></template>
          <el-menu-item index="1-1" @click="showProvider" v-if="limitList.includes(1)">供应商管理</el-menu-item>
          <el-menu-item index="1-2" @click="showClient" v-if="limitList.includes(2)">客户管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2" v-if="limitList.includes(3) || limitList.includes(4)">
          <template #title>
            <el-icon><DocumentAdd /></el-icon>
            <span>采购管理</span></template>
          <el-menu-item index="2-1" @click="showCaigou" v-if="limitList.includes(3)">采购入库</el-menu-item>
          <el-menu-item index="2-2" @click="showBuyInfo" v-if="limitList.includes(4)">采购信息查询</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="3" v-if="limitList.includes(5) || limitList.includes(6)">
          <template #title>
            <el-icon><SemiSelect /></el-icon>
            <span>销售管理</span></template>
          <el-menu-item index="3-1" @click="showSale" v-if="limitList.includes(5)">销售出库</el-menu-item>
          <el-menu-item index="3-2" @click="showSaleInfo" v-if="limitList.includes(6)">销售信息查询</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="4" v-if="limitList.includes(7)">
          <template #title>
            <el-icon><Collection /></el-icon>
            <span>库存管理</span></template>
          <el-menu-item index="4-1" @click="showGoods">库存一览</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="5" v-if="limitList.includes(8) || limitList.includes(9)">
          <template #title>
            <el-icon><Histogram /></el-icon>
            <span>统计信息</span></template>
          <el-menu-item index="5-1" @click="showSaleStats" v-if="limitList.includes(8)">销售统计</el-menu-item>
          <el-menu-item index="5-2" @click="showMonth" v-if="limitList.includes(9)">月销售统计</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="6" v-if="limitList.includes(10) || limitList.includes(11)">
          <template #title>
            <el-icon><UserFilled /></el-icon>
            <span>权限管理</span></template>
          <el-menu-item index="6-1" @click="showUser" v-if="limitList.includes(10)">用户管理</el-menu-item>
          <el-menu-item index="6-2" @click="showRole" v-if="limitList.includes(11)">角色管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="7">
          <template #title>
            <el-icon><Avatar /></el-icon>
            <span>个人信息管理</span></template>
          <el-menu-item index="7-1" @click="showPwd">修改密码</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="8" v-if="limitList.includes(12)">
          <template #title>
            <el-icon><InfoFilled /></el-icon>
            <span>日志信息</span></template>
          <el-menu-item index="8-1" @click="showLog">日志一览</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </el-col>
    <el-col :span="18">
      <router-view></router-view>
    </el-col>
  </el-row>



</template>

<script>
import axios from "axios";

export default {
  created() {
    console.log(localStorage)
    this.limitList = localStorage.getItem("list");
    axios.post("/api/user/findRealName",null).then(response=>{
      localStorage.setItem("userName",response.data);
    })
  },
  name: "Menu",
  data(){
    return{
      limitList:[]
    }
  },
  methods:{
    showProvider(){
      this.$router.push("/provider")
    },
    showClient(){
      this.$router.push("/client")
    },
    showCaigou(){
      this.$router.push("/caigou")
    },
    showBuyInfo(){
      this.$router.push("/buyInfo")
    },
    showSale(){
      this.$router.push("/sale")
    },
    showSaleInfo(){
      this.$router.push("/saleInfo")
    },
    showGoods(){
      this.$router.push("/goods")
    },
    showSaleStats(){
      this.$router.push("/saleStats")
    },
    showMonth(){
      this.$router.push("/month")
    },
    showUser(){
      this.$router.push("/user")
    },
    showRole(){
      this.$router.push("/role")
    },
    showPwd(){
      this.$router.push("/pwd")
    },
    showLog(){
      this.$router.push("/log")
    }
  }
}
</script>

<style scoped>

</style>